import 'package:flutter/material.dart';


//form表单项，带输入框
class LzTextFormField extends StatefulWidget {


  TextEditingController controller;
  String labelText;
  String hintText;
  String errorText;
  Icon icon;
  ValueChanged<String> onSave;
  ValueChanged<String> validator;
  bool obscureText;
  FocusNode focusNode;
  TextInputType keyboardType;

  LzTextFormField({this.controller, this.labelText, this.hintText,
    this.errorText, this.icon, this.onSave, this.validator, this.obscureText= false,this.focusNode,this.keyboardType});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new _LzTextFormFieldState();
  }
}

class _LzTextFormFieldState extends State<LzTextFormField> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Container(
      padding: EdgeInsets.only(top: 10),
      child: new TextFormField(
        controller: widget.controller,
        obscureText: widget.obscureText,
        focusNode: widget.focusNode,
        keyboardType: widget.keyboardType,
        decoration: new InputDecoration(
            prefixIcon: widget.icon,
            labelText: widget.labelText,
            errorText: widget.errorText,
            border: new OutlineInputBorder(
              borderRadius: new BorderRadius.circular(0),
            )),
        onSaved: widget.onSave,
        validator: widget.validator,
      ),
    );
  }
}